<?php

/**
 * irequest
 * Request class for iwebform
 * @author Talha Buğra Bulut talhabulut@hotmail.com
 */
class irequest {

    protected $params = array();
    protected $filter;

    public function __construct() {
        $this->params = $_REQUEST;

        require_once 'ifilter.php';
        $this->filter = new ifilter();
    }

    public function get_param($key, $filters=null) {
        if (isset($this->params[$key])) {
            if (is_array($filters)) {
                return $this->filter($this->params[$key], $filters);
            } else {
                return $this->params[$key];
            }
        } else {
            return null;
        }
    }

    public function get_params() {
        return $this->params;
    }

    public function filter($val, $filters) {
        return $this->filter->filter($val, $filters);
    }

    public function is_post_back() {
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
            return true;
        } else {
            return false;
        }
    }

}

?>